{{left_sidebar_enabled,right_sidebar_enabled=False,True}}
{{extend 'layout.html'}}

<link rel="stylesheet" href="{{=URL('static','css/form_comunicaciones.css')}}" type="text/css" media="all" />

<script>
    // Require the Dialog class
    require(["dijit/form/RadioButton","dijit/registry", "dojo/_base/xhr", "dojo/on", "dojo/dom", "dojo/dom-class", "dijit/TitlePane", "dojo/domReady!"], function(RadioButton,registry, xhr, on, dom, domClass, TitlePane) {
        
        var value_condicion = '{{=condicion}}';
        var value_comunicacion = '{{=comunicacion}}';
        
        xhr.get({
					// URL de la request
					url: "ver_datos_comunicacion",
					handleAs: "json",
					// Enviar los datos para checkear en la db 
					content: {
						id_comunicacion : value_comunicacion
					},
					load: function(response) {
						showDialog(response);
					}
				});

        ver_datos = function(){
        	xhr.get({
					// URL de la request
					url: "ver_datos_comunicacion",
					handleAs: "json",
					// Enviar los datos para checkear en la db 
					content: {
						id_comunicacion : value_comunicacion
					},
					load: function(response) {
						showDialog(response);
					}
				});
        }
        
        showDialog = function(response){
        	
        	var dialog = registry.byId("terms");
        	
        	switch (response.condicion){
        		case '1': //afiliado
	        		var result = '<table><tr><td class=w2p_fl><label>Condicion: </label></td><td>Afiliado</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>Nombre: </label></td><td>' +response.afiliado.nombre+ '</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>Tipo doc: </label></td><td>' +response.afiliado.tipo_documento+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>Nro doc: </label></td><td>' +response.afiliado.nro_documento+ '</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>CUIT: </label></td><td>' +response.afiliado.cuit+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>Telefono: </label></td><td>' +response.afiliado.telefono+ '</td></tr>';		    		        	
		       		result += '<tr><td class=w2p_fl><label>Mail: </label></td><td>' +response.afiliado.mail+ '</td></tr>';
		        	result += '</table>';
        		break;
        		case '3': //no afiliado
        			var result = '<table><tr><td class=w2p_fl><label>Condicion: </label></td><td>No Afiliado</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>Nombre: </label></td><td>' +response.no_afiliado.nombre+ '</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>Genero: </label></td><td>' +response.no_afiliado.genero+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>Telefono: </label></td><td>' +response.no_afiliado.telefono+ '</td></tr>';		    		        	
		       		result += '<tr><td class=w2p_fl><label>Mail: </label></td><td>' +response.no_afiliado.mail+ '</td></tr>';
		        	result += '</table>';
        		break;
        		case '2': //empleador
        			var result = '<table><tr><td class=w2p_fl><label>Condicion: </label></td><td>Empleador</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>Razon Social: </label></td><td>' +response.empleador.nombre+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>CUIT: </label></td><td>' +response.empleador.cuit+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>Telefono: </label></td><td>' +response.empleador.telefono+ '</td></tr>';		    		        	
		       		result += '<tr><td class=w2p_fl><label>Mail: </label></td><td>' +response.empleador.mail+ '</td></tr>';
		        	result += '</table>';
        		break;
        		case '4': //prestador
        			var result = '<table><tr><td class=w2p_fl><label>Condicion: </label></td><td>Prestador</td></tr>';
		        	result += '<tr><td class=w2p_fl><label>Nombre: </label></td><td>' +response.prestador.nombre+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>CUIT: </label></td><td>' +response.prestador.cuit+ '</td></tr>';
		       		result += '<tr><td class=w2p_fl><label>Telefono: </label></td><td>' +response.prestador.telefono+ '</td></tr>';		    		        	
		       		result += '<tr><td class=w2p_fl><label>Mail: </label></td><td>' +response.prestador.mail+ '</td></tr>';
		        	result += '</table>';
        		break;
        	}
        	
			var tp;
        	tp = new dijit.TitlePane({title:"DATOS DEL CONSULTANTE", content: result});
        	
        	dom.byId("titlepane").appendChild(tp.domNode);

        }
    });
</script>

<div id="titlepane" style="width: 450px; padding: 10px;">&nbsp;</div>
 

{{=form}}

{{if request.is_local:}}
{{=response.toolbar()}}
{{=form_error}}
{{pass}}


{{block right_sidebar}}
<!--{{=A(T("Administrative Interface"), _href=URL('admin','default','index'), _class='button',
     _style='margin-top: 1em;')}}-->
<h5>{{=T("Tips de atencion")}}</h5>

<ul>
	<li><span id="mision" class="tTip">misi&oacute;n</span></li>
	<li><span id="empatia" class="tTip">empat&iacute;a</span></li>
	<li><span id="atencion" class="tTip">atenci&oacute;n</span></li>
</ul>

<h5>{{=T("Links institucionales")}}</h5>

<ul>
  <!--<li>{{=A(T("Online examples"), _href=URL('examples','default','index'))}}</li>
  <li><a href="http://web2py.com">web2py.com</a></li>
  <li><a href="http://web2py.com/book">{{=T('Documentation')}}</a></li>-->
  <li>{{=LINK_COBERTURA}}</li>
  <li>{{=LINK_BENEFICIOS}}</li> 
  <li>{{=LINK_CARTILLAS}}</li> 
  <li>{{=LINK_CODEM}}</li>    
  <li>{{=LINK_OPCION_OBSBA}}</li>
  <li>{{=LINK_PADRON_SUPER}}</li>
  <li>{{=LINK_PROMOCION}}</li>  
  <li>{{=LINK_REQUISITOS_OPCION}}</li>
  <li>{{=LINK_REQUISITOS_AFILIACION}}</li>
  <li>{{=LINK_SALUD}}</li> 
  <li>{{=LINK_SEDES}}</li>
  <li>{{=LINK_TURISMO}}</li>  
  <li>{{=LINK_SALUD}}</li>  
  <li>{{=LINK_WEBMAIL}}</li>  
</ul>

{{end}}


<!-- 
	<button id="myButton">Buscar Afiliado</button>
	<script>
	require(["dojo/on", "dojo/dom", "dojo/_base/lang", "dojo/domReady!"],
    function(on, dom, lang) {
        
        var myScopedButton1 = dom.byId("myButton"),
        	tipo_doc = dom.byId("no_table_tipo_documento"),
        	nro_doc = dom.byId("no_table_nro_documento"),
            myObject = {
                id: "myObject",
                onClick: function(evt){
                	document.getElementById("no_table_nombre").value = "NOMBRE"
                	document.getElementById("no_table_apellido").value = "APELLIDO"
                    alert("The scope of this handler is " + this.id + " " + tipo_doc.value + " " + nro_doc.value);
                }
            };
 
        // This will alert "myScopedButton1"
        on(myScopedButton1, "click", myObject.onClick);
        // This will alert "myObject" rather than "myScopedButton2"
        //on(myScopedButton2, "click", lang.hitch(myObject, "onClick"));
 
});
</script>
-->